﻿
Imports xmlctrl
Imports xhtmlctrl
Imports webctrl

Public Class homepage
    Inherits cacheControlProcessor

    Public Const _pathidentity As String = "/"

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Public Overrides Function pathidentitylen() As Long
        Return strlen(pathidentity())
    End Function

    Protected Overrides Function processImpl(ByVal context As httpContext, ByRef control As xmlcontrol) As Boolean
        Dim page As xhtmlpage = Nothing
        page = context.createControl(New xhtmlpage(Nothing))
        page.addcsslink(staticrequest.generateStaticfileLinkUrl("homepage.css"))
        page.title().text = applicationSign() + " - homepage"

        Dim label As label = Nothing
        label = context.createControl(New label(Nothing))
        label.text = "Welcome to use " + applicationSign()
        label.id = "id_tit"
        label.class = "c_b"
        page.body().addchild(label)

        label = context.createControl(New label(Nothing))
        label.text = "this is an aggregator of rss seeds. please start to use with following introduction."
        label.id = "id_des"
        page.body().addchild(label)

        Dim ul As ul = Nothing
        ul = context.createControl(New ul(Nothing))
        ul.id = "id_inst_ul"
        page.body().addchild(ul)

        Dim li As li = Nothing
        li = context.createControl(New li(Nothing))
        li.class = "c_insts"
        ul.addchild(li)

        Dim a As a = Nothing
        a = context.createControl(New a(Nothing))
        a.text = "do a search to select css categories you are interesting in."
        a.href = strmid(searchpage._pathidentity, strlen(network.pathSeperator))
        li.addchild(a)

        li = context.createControl(New li(Nothing))
        li.class = "c_insts"
        ul.addchild(li)

        a = context.createControl(New a(Nothing))
        a.text = "submit some rss feeds you know, and share with others."
        a.href = strmid(inputpage._pathidentity, strlen(network.pathSeperator))
        li.addchild(a)

        Dim cite As cite = Nothing
        cite = context.createControl(New cite(Nothing))
        cite.text = applicationSign() + " will handle your rss feed, and serve it in several minutes."
        cite.class = "c_sub2 c_b"
        li.addchild(cite)

        li = context.createControl(New li(Nothing))
        li.class = "c_insts"
        ul.addchild(li)

        label = context.createControl(New label(Nothing))
        label.text = "or you do not know where to start, just let " + applicationSign() _
                     + " randomly selects several categories for you."
        li.addchild(label)

        label = context.createControl(New label(Nothing))
        label.text = "input random count of categories you prefer. < supported range 1 to " _
                     + Convert.ToString(rssrequest.maxRndCount) + " >"
        label.class = "c_sub2 c_b"
        li.addchild(label)

        Dim form As form = Nothing
        form = context.createControl(New form(Nothing))
        form.action = strmid(rssrequest._pathidentity, strlen(network.pathSeperator))
        form.class = "c_sub2"
        li.addchild(form)

        Dim input As input = Nothing
        input = context.createControl(New numberinput(Nothing))
        input.value = rnd(0, rssrequest.maxRndCount, True) + 1
        input.name = rssrequest.query.rnd
        input.id = "id_rnd"
        form.addchild(input)

        input = context.createControl(New input(Nothing))
        input.type = xhtmlctrl.input.type_enum.submit
        input.value = "submit"
        form.addchild(input)

        li = context.createControl(New li(Nothing))
        li.class = "c_insts"
        ul.addchild(li)

        cite = context.createControl(New cite(Nothing))
        cite.text = "reach me at "
        cite.id = "id_am"
        li.addchild(cite)

        a = context.createControl(New a(Nothing))
        a.text = config.adminmail
        a.href = config.adminmail
        cite.addchild(a)

        a = context.createControl(New a(Nothing))
        a.text = "or goto top level homepage " + config.adminlink + " to try other services"
        a.href = config.adminlink
        a.class = "c_b"
        cite.addchild(a)

        a = context.createControl(New a(Nothing))
        a.text = "or try if there is a readme.txt to see what is new in this version of " _
                 + applicationSign() + ", and if there is other issues"
        a.href = staticrequest.generateStaticfileLinkUrl("readme.txt")
        a.class = "c_b"
        cite.addchild(a)

        control = page
        Return True
    End Function
End Class
